package com.ce.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.ce.entity.Customer;
import com.ce.entity.Provider;
import com.ce.mapper.CustomerMapper;
import com.ce.service.CustomerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ce
 * @since 2022-01-02
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
    @Resource
    private CustomerMapper mapper;

    @Override
    public List<Customer> getList(Customer customer) {
        QueryWrapper<Customer> wrapper = new QueryWrapper<>();
        wrapper.like(StringUtils.isNotEmpty(customer.getCustomerNo()),"customer_no",customer.getCustomerNo());
        return mapper.selectList(wrapper);
    }

    @Override
    public Integer deleteById(Integer id) {
        Integer ret = mapper.deleteById(id);

        return ret;
    }

    @Override
    public Map<String, String> addCustomer(Customer customer) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("mode", "insert one Customer");
        mapper.insertCustomer(customer);
        return map;
    }

    @Override
    public Map<String, String> updateCustomer(Customer customer) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("mode", "update one Customer");
        mapper.updateById(customer);
        return map;
    }


}
